# encoding: utf-8
# @author: luzhangdan
# @file: login_api.py
# @time: 2021/10/19 15:10

from api.manage.manage_base import ManageBase
from common.encry_decry import RsaEncrypt


class LoginApi(ManageBase):
    def __init__(self, session):
        # 继承父类的初始化属性
        super().__init__()
        self.url = self.host + "cloudlottery-manage/login"
        self.method = "post"
        self.json = {
            "username": "luzhangdan",
            "password": RsaEncrypt('public_key.keystore', 'private_key.keystore').encrypt_data("Aa123456"),
            "verificationCode": "1234",
            "sessionId": session
        }


if __name__ == '__main__':
    from api.manage.getSession_api import GetSessionApi
    from common.parse import get_jsonpath_value

    result = GetSessionApi()
    res = result.send()
    login_session = get_jsonpath_value(res.text, '$.data')
    login = LoginApi(login_session)
    login.send()
